package com.cn.goodsadmin.controller;

import com.cn.goodsadmin.po.Logisticsdic;
import com.cn.goodsadmin.service.LogisticsService;
import com.cn.goodsadmin.util.ErrorMsg;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@CrossOrigin(origins = "*", maxAge = 3600)
@Controller
public class LogisticsController {

    @Autowired
    LogisticsService logisticsService;


    @LoginRequired
    @RequestMapping(value = "/getlogisticsdic", method = RequestMethod.GET)
    @ResponseBody//表示返回的是个json对象会经过配置文件转换
    public SupplyMap getLogisticsdic(@RequestParam(value = "content",required = false) String content) {
        SupplyMap supplyMap = new SupplyMap();
        try {
           List<Logisticsdic> logisticsdics=  logisticsService.findLogisticsDicByContent(content);
           if(logisticsdics!=null&&logisticsdics.size()>0) {
               supplyMap.put("logisticsdics", logisticsdics);
           }
        } catch (Exception e) {
            supplyMap.setEorrInfo(ErrorMsg.STATUS_DATABASE_ERROR, ErrorMsg.MSG_DATABASE_ERROR);
        }
        return supplyMap;
    }

}
